package replaceWords;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MarkDealXML {

	public String markdel(String withMark) {

		for (int i = 0; i < markList.size(); i++) {

			String mark = markList.get(i);
			// System.out.println(mark);
			String markSuccedaneum = markSuccedaneumsList.get(i);
			Pattern markPattern = Pattern.compile(mark);
			Matcher markMatcher = markPattern.matcher(withMark);
			withMark = markMatcher.replaceAll(markSuccedaneum);
			/*
			 * noMark = rs.getString("mark"); System.out.println(noMark);
			 */
		}

		// 单独处理空格
		Pattern kkPattern = Pattern.compile(" ");
		Matcher kkMatcher = kkPattern.matcher(withMark);
		withMark = kkMatcher.replaceAll("gg1000099hh");
		Pattern kkPattern2 = Pattern.compile("　　");
		Matcher kkMatcher2 = kkPattern2.matcher(withMark);
		withMark = kkMatcher2.replaceAll("gg1000095hh");
		// 单独处理英文双引号
		Pattern yinPattern = Pattern.compile("\"");
		Matcher yinMatcher = yinPattern.matcher(withMark);
		withMark = yinMatcher.replaceAll("gg1000098hh");
		// 单独处理换行
		Pattern hhPattern = Pattern.compile("\n");
		Matcher hhMatcher = hhPattern.matcher(withMark);
		withMark = hhMatcher.replaceAll("gg1000097hh");
		// 单独处理tab
		Pattern tabPattern = Pattern.compile("\t");
		Matcher tabMatcher = tabPattern.matcher(withMark);
		withMark = tabMatcher.replaceAll("gg1000096hh");
		return (withMark);

	}

	public String markAdd(String withMark) {

		for (int i = 0; i < markList.size(); i++) {

			String mark = markList.get(i);
			// System.out.println(mark);
			String markSuccedaneum = markSuccedaneumsList.get(i);
			Pattern markPattern = Pattern.compile(markSuccedaneum);
			Matcher markMatcher = markPattern.matcher(withMark);
			withMark = markMatcher.replaceAll(mark);
			/*
			 * noMark = rs.getString("mark"); System.out.println(noMark);
			 */
		}

		// 单独处理空格
		Pattern kkPattern = Pattern.compile("gg1000099hh");
		Matcher kkMatcher = kkPattern.matcher(withMark);
		withMark = kkMatcher.replaceAll(" ");
		Pattern kkPattern2 = Pattern.compile("gg1000095hh");
		Matcher kkMatcher2 = kkPattern2.matcher(withMark);
		withMark = kkMatcher2.replaceAll("　　");

		// 单独处理英文双引号
		Pattern yinPattern = Pattern.compile("gg1000098hh");
		Matcher yinMatcher = yinPattern.matcher(withMark);
		withMark = yinMatcher.replaceAll("\"");
		// 单独处理换行
		Pattern hhPattern = Pattern.compile("gg1000097hh");
		Matcher hhMatcher = hhPattern.matcher(withMark);
		withMark = hhMatcher.replaceAll("\n");
		// 单独处理tab
		Pattern tabPattern = Pattern.compile("gg1000096hh");
		Matcher tabMatcher = tabPattern.matcher(withMark);
		withMark = tabMatcher.replaceAll("\t");
		return (withMark);
	}

	List<String> markList = new ArrayList();
	public void setMarkList(List<String> markList) {
		this.markList = markList;
	}

	public void setMarkSuccedaneumsList(List<String> markSuccedaneumsList) {
		this.markSuccedaneumsList = markSuccedaneumsList;
	}

	List<String> markSuccedaneumsList = new ArrayList();

}
